home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / Demos / Herois / Codigo.Cst / 00061_Script_PopUp Drag < prev    next >
Text File  |  1999-03-19  |  3KB  |  112 lines

  1. property spriteList, len -- Sprites a serem movidos juntos
  2. property editableList 
  3. property permiteIdle
  4. property ligado
  5. property ondouble
  6.  
  7. on getBehaviorDescription
  8.   return "Arrasta sprites com o click do mouse"
  9. end
  10.  
  11. on getPropertyDescriptionList
  12.   set p_list = [ ¼
  13.     #spriteList: [ #comment:   "Lista de sprites a serem arrastados", ¼
  14.                     #format:   #list, ¼
  15.                    #default:    [0] ], ¼
  16.     #editableList: [ #comment: "Sprites editaveis que devem ser desligados antes de serem arrastados",¼
  17.                       #format: #list,¼
  18.                      #default:  [] ],¼
  19.     #permiteIdle: [ #comment:   "Permite funcionamento de outros sprites durante arraste", ¼
  20.                     #format:   #boolean, ¼
  21.                    #default:    false ], ¼
  22.     #ondouble: [ #comment:   "Permite funcionamento de outros sprites durante arraste", ¼
  23.                     #format:   #string, ¼
  24.                    #default:    "" ] ¼
  25.   ]
  26.   return p_list
  27. end
  28.  
  29. -- Guarda count para acesso rapido
  30. on beginSprite me
  31.   put count(spriteList) into len
  32.   set ligado = true
  33. end
  34.  
  35. -- Liga ou desliga sprites
  36. on chaveVisibilidade me, liga
  37.   if liga then
  38.     if not ligado then
  39.       repeat with i = 1 to len
  40.         put getAt(spriteList,i) into s
  41.         set the locV of sprite s to (the locV of sprite s) - 480
  42.       end repeat    
  43.     end if
  44.     set ligado = true
  45.   else
  46.     if ligado then
  47.       repeat with i = 1 to len
  48.         put getAt(spriteList,i) into s
  49.         set the locV of sprite s to (the locV of sprite s) + 480
  50.       end repeat    
  51.     end if
  52.     set ligado = false
  53.   end if
  54.   repeat with i = 1 to len
  55.     set the visible of sprite (getAt(spriteList,i)) to liga
  56.   end repeat
  57. end
  58.  
  59. -- Desloca todos os componetes do popup
  60. on moveRelativo me, dx, dy
  61.   repeat with i = 1 to len
  62.     put getAt(spriteList,i) into s
  63.     set the locH of sprite s to (the locH of sprite s) + dx
  64.     set the locV of sprite s to (the locV of sprite s) + dy
  65.   end repeat
  66. end
  67.  
  68. -- Liga/desliga campos editaveis: recomenda-se update stage
  69. -- depois
  70. on chaveEditaveis me, liga
  71.   put count(editableList) into l
  72.   repeat with i=1 to l
  73.     set the editable of sprite getAt(the editableList of me,i) to liga
  74.   end repeat
  75. end
  76.  
  77. on mouseDown me
  78.   -- Pega posicoes iniciais
  79.   put the mouseH into iniX
  80.   put the mouseV into iniY
  81.   
  82.   -- Desliga editaveis
  83.   chaveEditaveis me, false
  84.   if count(the editableList of me) > 0 then updateStage
  85.   
  86.   -- Loop enquanto pessoa segura mouse
  87.   repeat while the mouseDown
  88.     if the mouseV <> iniY or the mouseH <> iniX then
  89.       put the mouseV into mY
  90.       put the mouseH into mX
  91.       moveRelativo me, mX - iniX, mY - iniY
  92.       updateStage
  93.       put mY into iniY
  94.       put mX into iniX
  95.     end if
  96.     if permiteIdle then SendAllSprites(#IdleSprite)
  97.   end repeat
  98.   
  99.   -- Liga editaveis
  100.   chaveEditaveis me, true
  101.   if count(the editableList of me) > 0 then updateStage
  102. end
  103.  
  104. on mouseUp
  105.   if the doubleClick and ondouble <> "" then
  106.     global gPronde
  107.     set gPronde = 0
  108.     calculaDonde
  109.     sendAllSprites(#cleanSprite)
  110.     go frame ondouble
  111.   end if
  112. end